package cn.gok.day5;

import java.io.Serializable;

/**
 * @ClassName Role
 * @Description TODO
 * @Author HP
 * @Date 9:38 2022/7/8
 * @Version 1.0
 **/
public class Role implements Serializable {
    private String name;
    private int hp;
    private int mp;
    private String work;
//    让武器属性不序列化
//    private transient Wu wuqi;
//    要序列化的话，所引用对象也要实现Serializable接口
    private Wu wuqi;

    public Role(String name, int hp, int mp, String work, Wu wuqi) {
        this.name = name;
        this.hp = hp;
        this.mp = mp;
        this.work = work;
        this.wuqi = wuqi;
    }

    public Role() {
    }
    public void doWork(){
        System.out.println(this.name+"的职业是："+this.work);
    }

    public String getWork() {
        return work;
    }

    public Role(String name, int hp, int mp, String work) {
        this.name = name;
        this.hp = hp;
        this.mp = mp;
        this.work = work;
    }

    public Wu getWuqi() {
        return wuqi;
    }

    public void setWuqi(Wu wuqi) {
        this.wuqi = wuqi;
    }

    public void setWork(String work) {
        this.work = work;
    }

    public Role(String name, int hp, int mp) {
        this.name = name;
        this.hp = hp;
        this.mp = mp;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getHp() {
        return hp;
    }

    public void setHp(int hp) {
        this.hp = hp;
    }

    public int getMp() {
        return mp;
    }

    public void setMp(int mp) {
        this.mp = mp;
    }

    @Override
    public String toString() {
        return "Role{" +
                "name='" + name + '\'' +
                ", hp=" + hp +
                ", mp=" + mp +
                ", work='" + work + '\'' +
                ", wuqi=" + wuqi +
                '}';
    }
}
class Wu implements Serializable{
    private String wuqi;

    public String getWuqi() {
        return wuqi;
    }

    public void setWuqi(String wuqi) {
        this.wuqi = wuqi;
    }

    public Wu(String wuqi) {
        this.wuqi = wuqi;
    }

    public Wu() {
    }

    @Override
    public String toString() {
        return "wu{" +
                "wuqi='" + wuqi + '\'' +
                '}';
    }
}